home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / RKDUMB.PAS < prev    next >
Pascal/Delphi Source File  |  1991-04-29  |  1KB  |  41 lines

  1. PROCEDURE rkdumb(vstart: glnarray; nvar: integer; x1,x2: real; nstep: integer);
  2. (* Programs using routine RKDUMB must provide a
  3. PROCEDURE derivs(x:real; v:glnarray; VAR dvdx:glnarray);
  4. which returns the derivatives dvdx at location x, given both x and the
  5. function values v. They must also define the type
  6. TYPE
  7.    glnarray = ARRAY [1..nvar] OF real;
  8. where nvar is the number of functions. They must also
  9. declare the variables
  10. VAR
  11.    xx: ARRAY [1..200] OF real;
  12.    y: ARRAY [1..nvar,1..200] OF real;
  13. in the main routine. *)
  14. VAR
  15.    k,i: integer;
  16.    x,h: real;
  17.    v,vout,dv: glnarray;
  18. BEGIN
  19.    FOR i := 1 TO nvar DO BEGIN
  20.       v[i] := vstart[i];
  21.       y[i,1] := v[i]
  22.    END;
  23.    xx[1] := x1;
  24.    x := x1;
  25.    h := (x2-x1)/nstep;
  26.    FOR k := 1 TO nstep DO BEGIN
  27.       derivs(x,v,dv);
  28.       rk4(v,dv,nvar,x,h,vout);
  29.       IF (x+h = x) THEN BEGIN
  30.          writeln('pause in routine RKDUMB');
  31.          writeln('stepsize to small'); readln
  32.       END;
  33.       x := x+h;
  34.       xx[k+1] := x;
  35.       FOR i := 1 TO nvar DO BEGIN
  36.          v[i] := vout[i];
  37.          y[i,k+1] := v[i]
  38.       END
  39.    END
  40. END;
  41.